require "rubygems"
require "ai4r"
require File.dirname(__FILE__) + '/traning_play_tennis.rb'

net = Ai4r::NeuralNetwork::Backpropagation.new([4, 2])
trainning = TRANNING_PLAY_TENNIS

puts "Treinando a rede..."
1000.times do
	14.times do |i|
		error = net.train(trainning[i][0..3], trainning[i][4..5])  
		puts "Error after iteration #{i}:\t#{error}" if i%20 == 0
	end
end  

def result_label(result)
  if result[0] > result[1]
	"No"
	else  
	"Yes"
  end  
end

#puts "Exemplos de treino"
puts "Sunny Cool Normal Weak#{net.eval([0,2,1,0]).inspect} => #{result_label(net.eval([0,2,1,0]))}"
puts "Sunny Cool Normal Strong#{net.eval([0,2,1,1]).inspect} => #{result_label(net.eval([0,2,1,1]))}"
puts "Rain Cool Normal Strong#{net.eval([2,2,1,1]).inspect} => #{result_label(net.eval([2,2,1,1]))}"
